<template>
  <div class="content-container" style="position: relative">
    <div class="panel">
      <img class="system-logo-icon" src="@/assets/logo.png"></img>
      <div style="height: 10px"></div>
      <div style="text-align: start">
        <el-button type="success" @click="handleAppealRegister">申诉登记</el-button>
      </div>
      <div class="list-item"
           v-for="(item,index) in rightProtectionList" :key="index">
        <div style="display: flex">
          <div class="wtlx00">{{ wtlx00Options[item.wtlx00] }}</div>
          <div style="flex: 1; text-align: end;">
            <span style="margin-right: 10px; margin-top: 10px">{{ item.cjsj00 }}</span>
          </div>
        </div>
        <div class="wtms00">{{ item.wtms00 }}</div>
      </div>
      <empty-data-panel v-if="rightProtectionList.length===0"></empty-data-panel>
      <div class="position-page-bar" v-show="rightProtectionList.length > 0">
        <button class="btn" v-show="queryParam.page !== 1" @click="pageQuery('last')">上一页</button>
        <button class="btn" v-show="queryParam.page !== queryParam.pageTotal" @click="pageQuery('next')">下一页
        </button>
      </div>
      <appeal-register :dialog-visible="appealRegisterDialogVisible" @handleSuccess="handleSuccess" @handleClose="handleClose"></appeal-register>
    </div>

  </div>
</template>

<script>
import {equityMaintainApi} from "@/api/index.js"
import AppealRegister from '@/views/equity-maintain/register.vue'

export default {
  name: "equity-maintain",
  components: {
    AppealRegister
  },
  data() {
    return {
      queryParam: {
        page: 1,
        limit: 10,
        pageTotal: 0
      },
      rightProtectionList: [],
      wtlx00Options: {
        "1": "劳动报酬",
        "2": "工伤医疗",
        "3": "经济补偿",
        "4": "其他问题"
      },
      appealRegisterDialogVisible: false
    }
  },
  created() {
    this.queryRightProtectionList()
  },
  methods: {
    queryRightProtectionList() {
      equityMaintainApi.queryRightProtectionList({...this.queryParam}).then(res => {
        this.rightProtectionList = res.data.records
        this.queryParam.pageTotal = res.data.pageTotal
      })
    },
    pageQuery(type) {
      if (type === 'next') {
        this.queryParam.page = this.queryParam.page + 1
        this.queryRightProtectionList()
      } else {
        if (this.queryParam.page !== 1) {
          this.queryParam.page = this.queryParam.page - 1
          this.queryRightProtectionList()
        }
      }
    },
    handleAppealRegister() {
      this.appealRegisterDialogVisible = true
    },
    handleSuccess() {
      this.appealRegisterDialogVisible = false
      this.queryRightProtectionList()
    },
    handleClose() {
      this.appealRegisterDialogVisible = false
    }
  }
}
</script>

<style scoped lang="scss">
.panel {
  width: 70%;
  margin-right: auto;
  margin-left: auto;
  color: white;
  overflow-y: auto;

  .title {
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20%;
    height: 60px;
    font-size: xx-large;
    margin: 0 auto 15px auto;
    background-color: #1b78d5;
  }

  .list-item {
    position: relative;
    border-radius: 8px;
    line-height: 40px;
    font-size: large;
    margin-top: 15px;
    background-color: rgba(82, 72, 156, 0.2);

    .wtlx00 {
      font-size: 20px;
      margin-left: 20px;
      text-align: left;
      padding: 5px 0;
      font-weight: bold;
      text-decoration-line: underline;
    }

    .wtms00 {
      text-indent: 2ch;
      //margin-left: 5px;
      text-align: left;
      font-size: 18px;
      padding: 5px;
    }

    .more {
      position: absolute;
      right: 10px;
      bottom: 10px;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      font-size: 12px;

      span {
        padding: 3px;
      }

      img {
        width: 18px;
        height: 18px;
      }
    }

  }
  .position-page-bar {
    text-align: center;
    display: flex;
    margin-top: 10px;
    padding-bottom: 10px;

    .btn {
      margin: auto;
      width: 243px;
      height: 63px;
      line-height: 20px;
      border-radius: 16px;
      background-color: rgba(64, 149, 229, 0.8);
      color: rgba(16, 16, 16, 1);
      text-align: center;
      font-family: Roboto;
      border: 1px solid white;
      font-size: 30px;
      color: white;
    }
  }


}
</style>